package com.water.service.impl;

import com.water.dao.PyBalanceDao;
import com.water.entity.PyBalance;
import com.water.service.PyBalanceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (PyBalance)表服务实现类
 *
 * @author makejava
 * @since 2020-12-22 18:39:09
 */
@Service("pyBalanceService")
public class PyBalanceServiceImpl implements PyBalanceService {
    @Resource
    private PyBalanceDao pyBalanceDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PyBalance queryById(Integer id) {
        return this.pyBalanceDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<PyBalance> queryAllByLimit(int offset, int limit) {
        return this.pyBalanceDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param pyBalance 实例对象
     * @return 实例对象
     */
    @Override
    public PyBalance insert(PyBalance pyBalance) {
        this.pyBalanceDao.insert(pyBalance);
        return pyBalance;
    }

    /**
     * 修改数据
     *
     * @param pyBalance 实例对象
     * @return 实例对象
     */
    @Override
    public PyBalance update(PyBalance pyBalance) {
        this.pyBalanceDao.update(pyBalance);
        return this.queryById(pyBalance.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.pyBalanceDao.deleteById(id) > 0;
    }
}